package com.bite.deom2;

import java.sql.SQLOutput;
import java.util.Arrays;

public class Test {

    public static void bubblr(Comparable[] comparable) {
        for(int i = 0; i < comparable.length - 1; i++) {
            for(int j = 0; j < comparable.length - 1 - i; j++) {
                if(comparable[j].compareTo(comparable[j+1]) > 0) {
                    Comparable ret = comparable[j];
                    comparable[j] = comparable[j+1];
                    comparable[j+1] = ret;
                }
            }
        }
    }

    public static void main(String[] args) {
        Student student1 = new Student("changsan", 18);
        Student student2 = new Student("disi", 19);
        Student student3 = new Student("wangwu", 16);
        Student student4 = new Student("hangwu", 20);
        Student student5 = new Student("langwu", 9);
        Student[] students = {student1, student2, student3, student4, student5};
        bubblr(students);
        System.out.println(Arrays.toString(students));

    }

    public static void main1(String[] args) {
        Student student1 = new Student("changsan", 18);
        Student student2 = new Student("disi", 19);
        Student student3 = new Student("wangwu", 16);
        Student[] students = {student1, student2, student3};
//        int[] ints = {1,2,3,4,5,6,7,8};
//        Student[] students = {student1, student2, student3};
//        System.out.println(Arrays.toString(students));
//        System.out.println(Arrays.toString(ints));
        IAgeComparator iAgeComparator = new IAgeComparator();
        int ret = iAgeComparator.compare(student1, student2);
        System.out.println(ret);

        INaneComparator iNaneComparator = new INaneComparator();
        int cum = iNaneComparator.compare(student1, student2);
        System.out.println(cum);

        Arrays.sort(students,iAgeComparator);
        System.out.println(Arrays.toString(students));

        System.out.println(student1);

    }

}
